package com.ly.mpayment.rest.system;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.ly.mpayment.core.util.JsonUtils;
import com.ly.mpayment.core.util.MapUtil;
import com.ly.mpayment.core.util.ResultMessage;
import com.ly.mpayment.core.util.StringUtils;
import com.ly.mpayment.persist.service.upproductlog.IUpProductLogService;
import com.ly.mpayment.persist.service.user.IUserService;
import com.ly.mpayment.rest.AbsRest;

import net.sf.json.JSONObject;

@Component
@Path("system/upproductlog/")
public class UpProductLogRest extends AbsRest{

	@Autowired
	IUserService userService;

	@Autowired
	IUpProductLogService logService;

	@SuppressWarnings("static-access")
	@Path("findPageUpProductLog")
	@POST
	public String findPageUpProductLog(String data,@Context HttpServletRequest request){
		String result = this.validationParameterGetRole(request, userService);
		if(result == null){
			JSONObject json = JSONObject.fromObject(data);
			Map<String, Object> parameters = MapUtil.getMap();
			if(!StringUtils.isBlank(json.getString("starttime"))){
				parameters.put(":starttime", json.getString("starttime"));
			}

			if(!StringUtils.isBlank(json.getString("endtime"))){
				parameters.put(":endtime", json.getString("endtime"));
			}

			if(!StringUtils.isBlank(json.getString("useruuid"))){
				parameters.put(":useruuid", json.getString("useruuid"));
			}
			return ResultMessage.getSucceed( JsonUtils.excludes(logService.findPageUpproductlog(parameters, json.getInt("start"), json.getInt("pageSize")),
					new String[]{"","provincialInformation","operators","businessType","useruuid","password","phonenum",
							"userstatus","usertype","errorCodesForUseruuid","expire","wechatid","lastlogintime","token"}));
		}
		return result;
	}
}
